//by qyzyq
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
int n, T;
typedef pair<int,int> PII;
PII a[N];
int r[N];

int main()
{
	freopen ("sort.in", "r", stdin);
	freopen ("sort.out", "w", stdout);
	scanf("%d%d", &n, &T);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i].first),
		a[i].second = i;
	sort(a + 1, a + 1 + n); 
	for (int i = 1; i <= n; i++)
		r[a[i].second] = i; 
	while (T--)
	{
		int op;
		scanf("%d", &op);
		if (op == 1)
		{
			int x, y;
			scanf("%d%d", &x, &y);
			int it = 1;
			while (a[it].second != x) ++ it;
			a[it].first = y;
			int pos = it;
			while (a[it].first > a[it + 1].first || (a[it].first == a[it + 1].first && a[it].second > a[it + 1].second)) 
				++ it; 
			for (int i = pos + 1; i <= it; i++) r[a[i].second]--;
			r[a[pos].second] = it;
			swap (a[pos], a[it]);
		}
		else
		{
			int x;
			scanf("%d", &x);
			printf("%d\n", r[x]);
		}
	}
	return 0;
}
